#include "headfiles.h"

NODE * findNthLastNode(NODE *head, unsigned int n) {
	unsigned int i = 0;
	NODE *node, *ret_node;
	node = head;
	while (node != NULL && i < n) {
		node = node->next;
		++i;
	}

	// number of nodes is less than n
	if (node == NULL) {
		return NULL;
	}

	ret_node = head;
	while (node) {
		ret_node = ret_node->next;
		node = node->next;
	}

	return ret_node;
}

